package com.internetCafes.spms.web.customer.controller;


import com.internetCafes.spms.common.utils.entity.RR;
import com.internetCafes.spms.common.utils.entity.page.PageItemDTO;
import com.internetCafes.spms.common.utils.entity.page.PageItemVO;
import com.internetCafes.spms.web.customer.bizservice.msg.IEntMsgBizService;
import com.internetCafes.spms.web.customer.model.msg.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.internetCafes.spms.common.base.BaseWebController;

import java.util.List;

/**
 * <p>
 * 平台消息表 前端控制器
 * </p>
 *
 * @author Zj
 * @since 2021-10-25
 */
@RestController
@RequestMapping("/ent/msg")
public class MsgController extends BaseWebController {

    @Autowired
    private IEntMsgBizService msgBizService;

    /**
     * 分页
     */
    @PostMapping("/paging")
    @RequiresPermissions("ent:msg:paging")
    public RR<PageItemVO<MsgPagingRes>> paging(@RequestBody PageItemDTO<MsgPagingReq> req) {
        return RR.success(msgBizService.paging(req));
    }

    /**
     * 消息列表
     */
    @PostMapping("/list")
    @RequiresPermissions("ent:msg:list")
    public RR<List<MsgListRes>> list(@RequestBody MsgListReq req) {
        return RR.success(msgBizService.list(req));
    }

    /**
     * 当前用户未读消息数量统计
     */
    @GetMapping("/unread/count")
    @RequiresPermissions("ent:msg:unreadCount")
    public RR<UnReadCountRes> unReadCount() {
        return RR.success(msgBizService.unReadCount());
    }
}
